<?php

/**
 * This is the model class for table "{{kommunikation}}".
 *
 * The followings are the available columns in table '{{kommunikation}}':
 * @property integer $kom_id
 * @property integer $kom_type
 * @property integer $kom_ismain
 * @property string $kom_information
 * @property integer $org_id
 *
 * The followings are the available model relations:
 * @property Organisation $org
 */
class Kommunikation extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Kommunikation the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{kommunikation}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('kom_type, kom_ismain, org_id', 'numerical', 'integerOnly'=>true),
			array('kom_information', 'length', 'max'=>150),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('kom_id, kom_type, kom_ismain, kom_information, org_id', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'org' => array(self::BELONGS_TO, 'Organisation', 'org_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'kom_id' => 'Kom',
			'kom_type' => 'Type',
			'kom_ismain' => 'Main',
			'kom_information' => 'Information',
			'org_id' => 'Org',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('kom_id',$this->kom_id);
		$criteria->compare('kom_type',$this->kom_type);
		$criteria->compare('kom_ismain',$this->kom_ismain);
		$criteria->compare('kom_information',$this->kom_information,true);
		$criteria->compare('org_id',$this->org_id);

		return new CActiveDataProvider(get_class($this), array(
			'criteria'=>$criteria,
		));
	}
}